import React, { Fragment, useState } from 'react'
import { Col, Space, Typography, notification } from 'antd'
import AboutMask from './components/aboutMask';
const { Title } = Typography;
const LogicSetting = (props) => {
    const { data, selectIndex,
        list
    } = props
    const {
        option = []
    } = data
    console.log(data, '1231232')
    const [visible, setVisible] = useState(false)
    const openModel = () => {
        if (selectIndex >= list.length - 1) {
            return notification.warning({
                message: '错误提示',
                description: '此题为最后一题，没有可选的关联选项',
            });
        }
        else {
            setVisible({ show: true, detail: option })
        }
    }
    const filterBtnName = (

    ) => {
        return option.reduce((item, val) => {
            const { associationList = []
            } = val
            if (associationList.length > 0) {
                return '已设置，去修改'
            }
            else {
                return item
            }
        }, '未设置')
    }
    return <Fragment>
        <Col span={24}>
            <Title level={4}> 逻辑设置</Title>
        </Col>
        <Col span={24}>
            <Space style={{ width: '100%' }}>
                <div>题目关联</div>
                <div onClick={() => { openModel() }} style={{ marginLeft: 'auto', display: 'flex', color: '#999999', cursor: 'pointer', justifyContent: 'flex-end' }}>
                    {filterBtnName() + '>'}
                </div>
            </Space>
        </Col>
        <AboutMask {...props} visible={visible} onClose={() => { setVisible(false) }}></AboutMask>
    </Fragment>
}
export default LogicSetting